import unittest

from api.Ihrm_login_api import IhrmLoginApi
from common.assert_ulit import assert_ulit


class TestIhrmLogin(unittest.TestCase):
    # 登录成功
    def test01_login_ok(self):
        data = {"mobile": "13800000002", "password": "123456"}
        res = IhrmLoginApi.IhrmLogin(data)
        print("响应结果", res.json())
        # 断言
        assert_ulit(self,res,200,True,10000,'操作成功！')


    # 手机号为空
    def test01_mobile_none(self):
        data = {"mobile": None, "password": "123456"}
        res = IhrmLoginApi.IhrmLogin(data)
        print("响应结果", res.json())
        # self.assertEqual(200, res.status_code)
        # self.assertEqual(False, res.json().get("success"))
        # self.assertEqual(20001, res.json().get("code"))
        # self.assertIn('用户名或密码错误', res.json().get("message"))

        # 断言
        assert_ulit(self, res, 200, False, 20001, '用户名或密码错误')

    # 密码错误
    def test01_password_error(self):
        data = {"mobile": "13800000002", "password": "12345678"}
        res = IhrmLoginApi.IhrmLogin(data)
        print("响应结果", res.json())
        # self.assertEqual(200, res.status_code)
        # self.assertEqual(False, res.json().get("success"))
        # self.assertEqual(20001, res.json().get("code"))
        # self.assertIn('用户名或密码错误', res.json().get("message"))

        # 断言
        assert_ulit(self, res, 200, False, 20001, '用户名或密码错误')
